#! /bin/bash
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi

echo '========================================'
echo '==============开始全量导入==============='
echo '========================================'

echo '==============开始customer全量导入==============='
# customer

 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from customer  where 1=1  and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table customer  \
-m 1
wait
echo '==============开始customer_appeal全量导入==============='
# customer_appeal

 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from customer_appeal  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table customer_appeal  \
-m 1
wait
echo '==============开始customer_clue全量导入==============='
# customer_clue

 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from customer_clue  where 1=1  and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table customer_clue  \
-m 1
wait


echo '==============开始customer_relationship全量导入==============='
# customer_relationship

 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from customer_relationship  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table customer_relationship  \
-m 1
wait
echo '==============开始employee全量导入==============='
# employee
 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from employee  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table employee  \
-m 1
wait
echo '==============开始itcast_clazz全量导入==============='
# itcast_clazz
 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *, '${TD_DATE}' as dt from itcast_clazz  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table itcast_clazz  \
-m 1
wait
echo '==============开始itcast_school全量导入==============='
# itcast_school
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_school  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table itcast_school \
-m 1
wait
echo '==============开始itcast_subject全量导入==============='
# itcast_subject
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_subject  where 1=1 and  \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table itcast_subject \
-m 1
wait
echo '==============开始scrm_department全量导入==============='
# scrm_department
 /usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select *,'${TD_DATE}' as dt from scrm_department  where 1=1 and \$CONDITIONS" \
--hcatalog-database bxg_ods \
--hcatalog-table scrm_department  \
-m 1
wait

echo '========================================'
echo '=================success==============='
echo '========================================'